<?php
// +----------------------------------------------------------------------
// | OpenCMF [ Simple Efficient Excellent ]
// +----------------------------------------------------------------------
// | Copyright (c) 2014 http://www.yiban.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: jry <598821125@qq.com>
// +----------------------------------------------------------------------
namespace Home\Controller;

use Think\Controller;

/**
 * 前台默认控制器
 * @Administrator
 */
class IndexController extends HomeController
{
    /**
     * 默认方法
     * @Administrator
     */
//    public function index()
//    {
//        Cookie('__forward__', C('HOME_PAGE'));
//        $this->assign('meta_title', "首页");
//
//
//        $this->display();
//    }

    public function getIndexList($id){
        // 获取文档列表

        $base_table = C('DB_PREFIX') . "cms_index";
        $extend_table = strtolower(C('DB_PREFIX') . "cms" . '_' . "article");

        // 获取分类信息

        $map['cid'] = $id;
        $map['status'] = array('eq', 1);
        $document_list1 = D('CmsIndex')
            ->order('sort desc,' . $base_table . '.id desc')
            ->field('ls_cms_index.id,title,update_time')
            ->where($map)
            ->join($extend_table . ' ON ' . $base_table . '.id = ' . $extend_table . '.id')
            ->limit(6)
            ->select();
        return $document_list1;
    }

    public function index()
    {
        $map['status'] = array('eq', 1);
        $base_table= C('DB_PREFIX') . "admin_slider";
        $extend_table = strtolower(C('DB_PREFIX') . "admin" . '_' . "upload");

//        $slider_list=D("AdminSlider")->order($base_table . '.id desc')
//            ->where($map)
//            ->join($extend_table . ' ON ' . $base_table . '.cover = ' . $extend_table . '.id')
//            ->select();
//
//        print_r($slider_list);

        $slider_list=D("AdminSlider")->where($map)->select();
//        print_r($slider_list);
//        print_r($this->getIndexList(1));



        Cookie('__forward__', C('HOME_PAGE'));
        $this->assign('meta_title', "首页");
        $this->assign('volist1',$this->getIndexList(1) );
        $this->assign('slider',$slider_list);
        $this->assign('volist2',$this->getIndexList(2) );
        $this->assign('volist3',$this->getIndexList(3) );
        $this->assign('volist4',$this->getIndexList(4) );
        $this->display();
    }




    /**
     * 单页类型
     * @Administrator
     */
    public function page($id)
    {
        $nav_object = D('Admin/Nav');
        $con['id'] = $id;
        $con['status'] = 1;
        $info = $nav_object->where($con)->find();

        Cookie('__forward__', C('HOME_PAGE'));
        $this->assign('info', $info);
        $this->assign('meta_title', $info['title']);
        $this->display();
    }
}
